YAHOO.namespace("ajaxstack");
YAHOO.ajaxstack.ASObjectTests = new YAHOO.tool.TestCase({

	name: "ASObject Tests",

	//--------------------------------------------- 
	// Setup and tear down 
	//---------------------------------------------

	setUp: function()
	{
		function SubASObject(p1)
		{
			SubASObject.$baseConstructor.call(this);
			this.p1 = p1;
			this.instanceValue = "instance";
		}
		SubASObject.extend(AjaxStack.ASObject, { type: 'SubASObject' });
	},

	tearDown: function()
	{
	},

	//--------------------------------------------- 
	// Tests
	//---------------------------------------------

	testClass: function()
	{
		var sub1 = new SubASObject('sub1');
		Assert.areEqual('SubASObject', sub1.getType());
		Assert.areEqual('SubASObject', SubASObject.getType());
		ArrayAssert.itemsAreEqual(['SubASObject', 'AjaxStack.ASObject', 'AjaxStack.Class'],
			sub1.getBaseTypesAndSelf());
	},

	testLogger: function()
	{
		var sub1 = new SubASObject('sub1');
		Assert.areEqual('sub1', sub1.p1);
		Assert.areEqual('instance', sub1.instanceValue);
		Assert.isNotNull(sub1.log);
		Assert.areEqual(SubASObject.getType(), sub1.log.category);
	},

	testGetFactoryFn: function()
	{
		var sub1 = new SubASObject('sub1');
		Assert.areEqual('instance', sub1.instanceValue);

		var sub2 = sub1.getFactoryFn()();
		Assert.areEqual('instance', sub2.instanceValue);
		Assert.areEqual('instance', sub2.instanceValue);
		Assert.areEqual('SubASObject', sub2.getType());
		ArrayAssert.itemsAreEqual(['SubASObject', 'AjaxStack.ASObject', 'AjaxStack.Class'],
			sub2.getBaseTypesAndSelf());
	}

});

